//
// Created by hay boy on 2022/6/20.
//

#ifndef ALGORITHMS_DOUBLYLINKEDLIST_H
#define ALGORITHMS_DOUBLYLINKEDLIST_H
#include "../linearList/ExtendedLinearList.h"
#include "ChainNode.h"
template<class T>
class DoublyLinkedList:public ExtendedLinearList<T> {
public:
    DoublyLinkedList();
    ~DoublyLinkedList();
    bool empty()const{
        return listSize == 0;
    }
    int size() const{
        return listSize;
    }
    int indexOf(const T& theElement) const;
    T& get(int theIndex)const;
    void erase(int theIndex);
    void insert(int theIndex,const T& theElement);
    void output(ostream& out) const;
    void clear();
    void push_back(const T& theElement);
    template<class Y>
    friend ostream &operator<<(ostream &out, const DoublyLinkedList<Y> &x);
protected:
    void checkIndex(int theIndex) const;
    BidirectionalNode<T>* firstNode;
    BidirectionalNode<T>* lastNode;
    int listSize{};
};
#endif //ALGORITHMS_DOUBLYLINKEDLIST_H
